// 小红的口罩(小堆)
#include <iostream>
#include <queue>
using namespace std;

int n, k, sum, res;
priority_queue<int, vector<int>, greater<int>> pq;

int main()
{
    cin >> n >> k;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        pq.push(a);
    }
    while (sum <= k)
    {
        res++;
        int t = pq.top();
        sum += t;
        pq.pop();
        pq.push(t * 2);
    }
    cout << res - 1 << endl;
    return 0;
}

// 春游(模拟)
#include <iostream>
using namespace std;

using ll = long long;
ll t, n, a, b;

int main()
{
    cin >> t;
    while (t--)
    {
        cin >> n >> a >> b;
        ll sum = 0;
        if (n <= 2) sum = min(a, b);
        else if (a * 3 < b * 2)
        {
            sum += n / 2 * a;
            if (n % 2) sum += min(min(a, b), b - a);
        }
        else
        {
            sum += n / 3 * b;
            if (n % 3 == 1) sum += min(min(a, b), 2 * a - b);
            if (n % 3 == 2) sum += min(min(a, b), 3 * a - b);
        }
        cout << sum << endl;
    }
    return 0;
}

// 数位染色(01背包)
#include <iostream>
#include <string>
using namespace std;

string s;
int sum;

int main() 
{
    cin >> s;
    for (auto ch : s) sum += (ch - '0');
    if (sum % 2 == 0)
    {
        sum /= 2;
        int dp[20][200] = {};
        int n = s.size();
        for (int i = 0; i <= n; i++) dp[i][0] = true;
        for (int i = 1; i <= n; i++)
        {
            for (int j = 0; j <= sum; j++)
            {
                dp[i][j] = dp[i - 1][j];
                if (j >= (s[i - 1] - '0'))  
                    dp[i][j] = dp[i][j] || dp[i - 1][j - (s[i - 1] - '0')];
            }
        }
        if (dp[n][sum]) 
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

#include <iostream>
#include <string>
using namespace std;

string s;
int sum;

int main() 
{
    cin >> s;
    for (auto ch : s) sum += (ch - '0');
    if (sum % 2 == 0)
    {
        sum /= 2;
        int dp[200] = {};
        int n = s.size();
        dp[0] = true;
        for (int i = 1; i <= n; i++)
            for (int j = sum; j >= (s[i - 1] - '0'); j--) 
                dp[j] = dp[j] || dp[j - (s[i - 1] - '0')];
        if (dp[sum]) 
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}
